﻿using Cl.Entity.DataBaseEntity.System;
using Microsoft.Extensions.Configuration;

namespace Cl.Repository.Sqlsugar
{
    public static class SqlsugarStep
    {
        public static AppDbContext? SqlSugarDbContext { get; set; }
        public static void InitDataBase(ConfigurationManager configurationManager)
        {
            //BaseDBConfig.ConnectionString = builder.Configuration.GetConnectionString("db_master");

            var strConnection = configurationManager.GetConnectionString("db_master");
            var strConnectionType = configurationManager.GetConnectionString("db_type");
            if (SqlSugarDbContext == null)
                SqlSugarDbContext = new AppDbContext(strConnection, strConnectionType);
            SqlSugarDbContext.CreateTable(false, 50);


        }


        #region 私有方法

        public static void InsertLoginLog(LoginLog loginLog)
        {
            if (SqlSugarDbContext != null)
            {
                SqlSugarDbContext.Db.Insertable(loginLog);
            }
        }

        #endregion
    }
}
